﻿
using LMM_Editor.Classes.CustomControls;
using LMM_Editor.Classes.Entities;
using LMM_Editor.Classes.System.Tools;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LMM_Editor.Classes.System
{
    //public delegate IEntity onClick(object sender, ClickEventArgs click);


    public enum ToolType
    {
        Select=0,
        Create=1
    }
    public class Tool
    {
        public string name;
        public string description;
        public ToolType tooltype;
        public ToolManager parent;


        public Tool()
        {
            name = "Tool_Default";
            description = "Tool_Default";
            tooltype = ToolType.Create;
        }

        public virtual IEntity useTool(double x, double y, Control parent, IEntity entity)
        {
            // Override this for tool function
            return null;
        }

        public virtual IEntity onClick(object sender, ClickEventArgs args)
        {
            return null;
        }

        public virtual IEntity onClickRelease(object sender, ClickEventArgs args)
        {
            return null;
        }
        public virtual IEntity useToolEnd(double x, double y, Control parent, IEntity entity)
        {
            return null;
        }

        public void useToolConvert(object sender, MouseEventArgs e)
        {
            IEntity entity = EntityManager.findEntity((Control)sender);

            onClick(sender, getClickEventArgs(e, entity));
        }

        public ClickEventArgs getClickEventArgs(MouseEventArgs e, IEntity entity)
        {
            ClickEventArgs cevent = new ClickEventArgs();
            cevent.entity = entity;
            cevent.x = e.X;
            cevent.y = e.Y;
            return cevent;
        }

        public virtual void useToolEndConvert(object sender, MouseEventArgs e)
        {
            IEntity entity = EntityManager.findEntity((Control)sender);
            
            onClickRelease(sender, getClickEventArgs(e, entity));
        }
    }
}
